<?php
class Food{}

class AnimalFood extends Food {}


abstract class Animal {
    public function __construct(protected string $name) {}

    public function eat(AnimalFood $food)
    {
        echo $this->name . " eats " . get_class($food);
    }
}

class Dog extends Animal{

    public function eat(Food $food){
        echo $this->name . " eats " . get_class($food);
    }
}

class Cat extends Animal{
    public function eat(Food $food){
        echo $this->name . " eats " . get_class($food);
    }
}

interface AnimalShelter{
    public function adopt(string $name): Animal;
}

class CatShelter implements AnimalShelter {
    public function adopt(string $name): Cat {
        return new Cat($name);
    }
}

class DogShelter implements AnimalShelter {
    public function adopt(string $name): Dog{
        return new Dog($name);
    }
}

$kitty = (new CatShelter)->adopt("Ricky");

$catFood = new AnimalFood();
$kitty->eat($catFood);
echo "\n";

$doggy = (new DogShelter)->adopt("Mavrick");
$banana = new Food();
$doggy->eat($banana);






